home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / utils / noguru / noguru.s
Text File  |  1980-01-03  |  4KB  |  116 lines

  1. *******************************************************************************
  2. * NoGuru                     Copyright © 1992/94 2-Cool/LSd
  3. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  4. * Simple and small program to redirect guru-meditations to a Soft-Reset routine
  5. * so that the Amiga quickly reboots instead of having to go through multiple
  6. * crashes that can lock the machine. The Program SHOULD ONLY BE EXECUTED *ONCE*
  7. * All other re-executions of the program will simply abort peacefully! This is
  8. * a very simple`n`quick hack written in 5 mins to stop crashes locking up 
  9. * BBS`s for hours on end!
  10. *
  11. * Once installed and it requires only 48 bytes!!! Warning only execute from
  12. * CLI, not from WB! Simply add it to your "startup-sequence" AFTER SetPatch!
  13. *
  14. * Features:    » Once installed takes up NO CPU time whatsoever
  15. *        » Supports Relocated/Non-Relocated VBR (Vector Base Register)
  16. *        » Handles MMU Errors
  17. *        » Handles FPU Errors
  18. *        » Handles CO-PROCESSOR Errors
  19. *        » Reset code uses cache of Execbase Ptr for some more saftey
  20. *        » Compatible with any version of kickstart!
  21. *******************************************************************************
  22. _LVOAllocMem:    equ    -$C6
  23. _LVOSupervisor:    equ    -$1E
  24. AbsExecBase:    equ    $4
  25. AttnFlags:    equ    $128
  26.  
  27.         section    NoGuru,code        ;public memory
  28.  
  29. *-------------- Get VectorBase Register
  30.  
  31. FindVBR:    lea    _ExecBase(pc),a0
  32.         move.l    (AbsExecBase).w,a6
  33.         move.l    a6,(a0)            ;cache execbase ptr!
  34.         suba.l    a4,a4            ;a4=0.l
  35.         move.w    AttnFlags(a6),d1    ;get cpu type
  36.         and.w    #15,d1            ;are we on M68000
  37.         beq.s    NoVBR            ;if so skip
  38.  
  39.         lea    GetVBR(pc),a5        ;ptr to VBR Get code
  40.         jsr    _LVOSupervisor(a6)
  41.  
  42. *-------------- Check if we are already installed!
  43.  
  44. NoVBR:        cmp.l    #$FADEDEAD,$d8(a4)    ;is it already installed?
  45.         beq.s    ExitCLI
  46.  
  47. *-------------- Allocate memory for reset code
  48.  
  49.         moveq    #ResetEnd-ForceReset+4,d0
  50.         moveq    #0,d1
  51.         jsr    _LVOAllocMem(a6)    ;allocate some memory
  52.         tst.l    d0
  53.         beq.w    ExitCLI
  54.  
  55. *-------------- Relocate Reset Code into Allocated memory
  56.  
  57.         addq.w    #2,d0
  58.         bclr    #0,d0            ;word align
  59.         move.l    d0,a1
  60.         
  61.         lea    ForceReset(pc),a0
  62.         moveq    #(ResetEnd-ForceReset)-1,d1
  63. reloc_code:    move.b    (a0)+,(a1)+        ;relocate into allocmem
  64.         dbra    d1,reloc_code
  65.  
  66. *-------------- Patch Motorola Guru Error Handlers to my RESET Routine!
  67.  
  68.         move.l    #$FADEDEAD,$d8(a4)    ;id - hope it don`t get used!
  69.         move.l    d0,$08(a4)        ;Bus Error
  70.         move.l    d0,$0C(a4)        ;Address Error
  71.         move.l    d0,$10(a4)        ;Illegal Instruction
  72.         move.l    d0,$14(a4)        ;Divide by Zero
  73.         move.l    d0,$18(a4)        ;CHK Error
  74.         move.l    d0,$1C(a4)        ;Trapv Error
  75.         move.l    d0,$24(a4)        ;Trace Exception
  76.         move.l    d0,$28(a4)        ;$Axxx emulation
  77.         move.l    d0,$2C(a4)        ;$Fxxx emulation
  78.         move.l    d0,$34(a4)        ;CP-Violation
  79.         move.l    d0,$38(a4)        ;Format Error
  80.         move.l    d0,$C0(a4)        ;(FPCP Bra/Set Unordered Con)
  81.         move.l    d0,$C4(a4)        ;(FPCP Inexact Result)
  82.         move.l    d0,$C8(a4)        ;(FPCP Divide by Zero)
  83.         move.l    d0,$CC(a4)        ;(FPCP Underflow)
  84.         move.l    d0,$D0(a4)        ;(FPCP Operand Error)
  85.         move.l    d0,$D4(a4)        ;(FPCP Signalling Not-A-Number)
  86.         move.l    d0,$DC(a4)        ;(PMMU Configuration Error)
  87.         move.l    d0,$E0(a4)        ;(PMMU Illegal Operation)
  88.         move.l    d0,$E4(a4)        ;(PMMU Illegal Operation)
  89.         move.l    d0,$E8(a4)        ;(PMMU Access Level Violation)
  90. ExitCLI:    moveq    #0,d0
  91.         rts
  92.  
  93. GetVBR:        movec    vbr,d1
  94.         move.l    d1,a4
  95.         rte
  96.  
  97. *******************************************************************************
  98. * Perform Reset
  99. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  100. *******************************************************************************
  101.  
  102. ForceReset:    clr.l    0.w            ;bye bye guru no..
  103.         move.l    _ExecBase(pc),a6    ;get cache of execbase ptr!
  104.         clr.l    $26(a6)            ;kill exec chksum! bye bye exec
  105.         lea    ResetCode(pc),a5
  106.         move.w    #$ff0,$dff180        ;yellow flash!
  107.         jsr    _LVOSupervisor(a6)
  108.         rts
  109.         cnop    0,4
  110. ResetCode:    lea    2.w,a0
  111.         reset
  112.         jmp    (a0)
  113.  
  114. _ExecBase    dc.l    0
  115. ResetEnd:    even
  116.